import 'business_config_model.dart';

enum BusinessAdmobType {
  // 开屏广告
  appOpenAd,
  //插屏广告
  interstitialAd,
}

/// 业务配置管理类
class ConfigBusiness {
  // 当前配置
  static BusinessConfigModel? _config;

  // 防止实例化，保持为纯静态类
  ConfigBusiness._();

  // 初始化状态标记
  static bool _isInitialized = false;

  // 运行时状态变量
  static bool isLoadingShowAppOpenAd = false; //是否展示过开屏广告
  static void Function(bool)? adjustCallback; //是否是买量用户回调
  // static void Function(BusinessAdmobType)? adRequest; // 开始请求广告

  static String? deviceToken; // ios的推送令牌
  /// 初始化配置 - 只能调用一次
  static void initialize(BusinessConfigModel config) {
    if (_isInitialized) {
      throw StateError('ConfigBusiness已经初始化，不能重复初始化');
    }

    _config = config;
    _isInitialized = true;
  }

  /// 检查是否已初始化
  static bool get isInitialized => _isInitialized;

  /// 获取当前配置 - 添加非空检查
  static BusinessConfigModel get config {
    if (!_isInitialized) {
      throw StateError('ConfigBusiness尚未初始化，请先调用initialize方法');
    }
    return _config!;
  }

  ///更新扩展参数
  static void updateExtensionParams(Map<String, dynamic> params) {
    if (!_isInitialized) {
      throw StateError('ConfigBusiness尚未初始化，请先调用initialize方法');
    }
    _config?.reportExtraParameters = params;
  }
}
